<template>
  <div class="flot-menu" @mousedown.stop="stop" :class="'flot-menu-id' + props.selectInfoType">
    <div class="flot-menu-content">
      <t-tooltip content="更换素材">
        <div class="flot-menu-item" @click="replaceType">
          <i class="freeIcon">&#xe64f;</i>
        </div>
      </t-tooltip>
      <t-tooltip content="更多">
        <div ref="menuItemDom" class="flot-menu-item" @mouseenter="handleMouseEnter">
          <i class="doorIcon">&#xe667;</i>
        </div>

        <!-- <t-dropdown :max-column-width="120" :max-height="200" @click="clickHandler">
          
        </t-dropdown> -->
      </t-tooltip>
    </div>
  </div>
</template>
 
<script setup lang="ts">
import { ref } from 'vue';
import { FlotexbitListMenuShow } from '@/hooks/menuHooks';
import { useProjectStore } from '@/store';

const store = useProjectStore();
const props = defineProps({
  selectInfoType: {
    type: Number,
  },
  childId: {
    type: Number,
  },
  indexs: {
    type: Number,
  },
  contextmenuExhibitId: {
    type: Number,
  },
  materialType: {
    type: Number,
  },
  AuxiliaryId: {
    type: Number,
  },
});
const menuItemDom = ref();
const handleMouseEnter = (event) => {
  store.contextmenuchildId = props.childId;
  store.contextmenuGroupId = props.indexs;
  store.contextmenuExhibitId = props.contextmenuExhibitId;
  store.materialType = props.materialType;
  const rect = menuItemDom.value.getBoundingClientRect();
  const left = rect.left; // 元素左边距离窗口可视区域的距离
  const bottom = rect.top + 40; //window.innerHeight - rect.top; // 元素底部距离窗口可视区域的距离
  console.log(left, bottom);
  // let dom=document.querySelector('.flot-menu-id' + props.selectInfoType)
  
  FlotexbitListMenuShow(
    // menuItemDom.value, 
    { 
      x: left,
      y: bottom,
    },
    props.AuxiliaryId,
  );
};
const stop = (event) => {
  event.stopPropagation();
};
const replaceType = () => {
  store.contextmenuchildId = props.childId;
  store.contextmenuGroupId = props.indexs;
  store.contextmenuExhibitId = props.contextmenuExhibitId;
  store.materialType = props.materialType;
  store.selectAuxiliaryIndex = props.AuxiliaryId;
  store.setreplaceMaterialsShow(true);
};
</script> 

<style scoped lang="less">
.flot-menu {
  display: none;
  // display: flex;
  position: absolute;
  top: -52px;
  left: 50%;
  width: 80px;
  height: 40px;
  background: #ffffff;
  box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.1), 0px 8px 10px 1px rgba(0, 0, 0, 0.06),
    0px 3px 14px 2px rgba(0, 0, 0, 0.05);
  border-radius: 4px;
  border: 1px solid #f0f0f0;
  transform: translate(-50%, -0%);
  padding: 4px 8px;
  z-index: 777;
}

.flot-menu-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 32px;
  border-radius: 4px;
  .freeIcon {
    font-size: 24px;
    color: rgba(0, 0, 0, 0.59);
  }
  .doorIcon {
    font-size: 24px;
    color: rgba(0, 0, 0, 0.59);
  }
}

.flot-menu-item:hover {
  background: #f5f5f5;
}
.flot-menu-content {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 100%;
}
.adjust-menu {
  display: flex;
  flex-direction: column;
  position: absolute;
  left: 120px;
  top: 28px;
  width: 240px;
  height: auto;
  padding: 12px;
  background: #fff;
  border-radius: 4px;
}
.adjust-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  span {
    color: #000;
    font-size: 14px;
    margin-right: 16px;
  }
}
.silid-box {
  flex: 1;
}
:deep(.t-slider__button) {
  width: 12px;
  height: 12px;
}
</style>